/*
 * GameTile - graph node also containing all kinds of game pieces 
 *
 * Copyright 2007 James W. Hofmann
 *
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */

class GameTile
{

	// 'left' = negative
	// 'right' = positive

	public var xleft : GameTile;
	public var xright : GameTile;
	public var yleft : GameTile;
	public var yright : GameTile;
	
	public var x : Int;
	public var y : Int;
	
	// links is the iterable format of the above
	
	public var links : Array<GameTile>;
	
	// references to various other kinds of data used by the game; gameplay-type stuff and pathfinding values
	
	public var terrain : Int;
	public var fort : FortressData;
	public var creeps : Array<Creep>;
	public var territory : Int; // territory control: 0=player 1/2=outside player
	public var paths : Array<GameTile>;
	public var waterpaths : Array<GameTile>;
	public var shouldlandhere : Bool;
	
	public function new(x : Int, y : Int)
	{
		this.x = x;
		this.y = y;
		creeps = new Array();
		links = new Array();
		paths = [null,null,null];
		waterpaths = [null,null,null];
	}
	
	public function link(xl : GameTile, xr : GameTile, yl : GameTile, yr : GameTile)
	{
		xleft = xl;
		xright = xr;
		yleft = yl;
		yright = yr;
		
		for (n in [xl,xr,yl,yr])
		{
			if (n!=null)
				links.push(n);
		}
		
	}
	
}
